{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 36,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "                         1*1=1  \n",
      "                      2*1=2 2*2=4  \n",
      "                   3*1=3 3*2=6 3*3=9  \n",
      "                4*1=4 4*2=8 4*3=12 4*4=16  \n",
      "             5*1=5 5*2=10 5*3=15 5*4=20 5*5=25  \n",
      "          6*1=6 6*2=12 6*3=18 6*4=24 6*5=30 6*6=36  \n",
      "       7*1=7 7*2=14 7*3=21 7*4=28 7*5=35 7*6=42 7*7=49  \n",
      "    8*1=8 8*2=16 8*3=24 8*4=32 8*5=40 8*6=48 8*7=56 8*8=64  \n",
      " 9*1=9 9*2=18 9*3=27 9*4=36 9*5=45 9*6=54 9*7=63 9*8=72 9*9=81  \n"
     ]
    }
   ],
   "source": [
    "#以金字塔方式打印九九乘法表\n",
    "     \n",
    "\n",
    "for i in range(1,10):\n",
    "    for j in range(1,i+1):\n",
    "        if j==1:\n",
    "            print(\"   \"*(9-i),f\"{i}*{1}={i}\",end=\" \")\n",
    "        else:\n",
    "            print(f'{i}*{j}={i*j}',end=\" \")\n",
    "    print(\" \")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[('A', 'a'), ('B', 'b'), ('C', 'c'), ('D', 'd'), ('E', 'e'), ('F', 'f'), ('G', 'g'), ('H', 'h'), ('I', 'i'), ('J', 'j'), ('K', 'k'), ('L', 'l'), ('M', 'm'), ('N', 'n'), ('O', 'o'), ('P', 'p'), ('Q', 'q'), ('R', 'r'), ('S', 's'), ('T', 't'), ('U', 'u'), ('V', 'v'), ('W', 'w'), ('X', 'x'), ('Y', 'y'), ('Z', 'z')]\n",
      "A - a\n",
      "B - b\n",
      "C - c\n",
      "D - d\n",
      "E - e\n",
      "F - f\n",
      "G - g\n",
      "H - h\n",
      "I - i\n",
      "J - j\n",
      "K - k\n",
      "L - l\n",
      "M - m\n",
      "N - n\n",
      "O - o\n",
      "P - p\n",
      "Q - q\n",
      "R - r\n",
      "S - s\n",
      "T - t\n",
      "U - u\n",
      "V - v\n",
      "W - w\n",
      "X - x\n",
      "Y - y\n",
      "Z - z\n"
     ]
    }
   ],
   "source": [
    "#1.将所有大小写英文字母的字符以成对的形式放到一个数组中，要求每对是一个元组，比如[('A','a'),('B','b'),...]；并将他们按行打印出来，要求每行打印一组，格式如下:\n",
    "  #A - a\n",
    "  #B - b\n",
    "import string\n",
    "#help(string)\n",
    "def dui(a,b,d):\n",
    "\n",
    "    for i in range(len(a)):\n",
    "        c = (b[i],a[i])\n",
    "        d.append(c)\n",
    "    print(d)\n",
    "    for i in range(len(d)):\n",
    "        print(d[i][0],\"-\",d[i][1])\n",
    "a = string.ascii_lowercase\n",
    "b = string.ascii_uppercase\n",
    "d = []\n",
    "dui(a,b,d)\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "26938236\n"
     ]
    },
    {
     "ename": "FileNotFoundError",
     "evalue": "[Errno 2] No such file or directory: 'C:\\\\Users\\\\未来可期\\\\Desktop.txt'",
     "output_type": "error",
     "traceback": [
      "\u001b[1;31m---------------------------------------------------------------------------\u001b[0m",
      "\u001b[1;31mFileNotFoundError\u001b[0m                         Traceback (most recent call last)",
      "\u001b[1;32m<ipython-input-3-93eb978de5e0>\u001b[0m in \u001b[0;36m<module>\u001b[1;34m\u001b[0m\n\u001b[0;32m      9\u001b[0m \u001b[1;31m#2.查找资料，将常用汉字（20000个左右）及其unicode编码（十六进制形式） 打印出来\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m     10\u001b[0m   \u001b[1;31m#要求： 汉字的unicode编码（十六进制形式）的前两位相同的放在同一行，比如：\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[1;32m---> 11\u001b[1;33m \u001b[1;32mwith\u001b[0m \u001b[0mopen\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;34mr'C:\\Users\\未来可期\\Desktop.txt'\u001b[0m\u001b[1;33m)\u001b[0m \u001b[1;32mas\u001b[0m \u001b[0mf\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m\u001b[0;32m     12\u001b[0m           \u001b[0ma\u001b[0m \u001b[1;33m=\u001b[0m \u001b[0mf\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mread\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m     13\u001b[0m \u001b[1;32mfor\u001b[0m \u001b[0mj\u001b[0m \u001b[1;32min\u001b[0m \u001b[0mrange\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mlen\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0ma\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n",
      "\u001b[1;31mFileNotFoundError\u001b[0m: [Errno 2] No such file or directory: 'C:\\\\Users\\\\未来可期\\\\Desktop.txt'"
     ]
    }
   ],
   "source": [
    "#1.计算10000以内所有3,7,13,19,23,29的倍数的正整数的和并分别打印出来\n",
    "def qiuhe(m):\n",
    "    for i in range(10000):\n",
    "        if i%3==0 or i%7 == 0 or i%13==0 or i%19==0 or i%23==0 or i%29 == 0:\n",
    "            m = m+i\n",
    "    return m\n",
    "m = 0\n",
    "print(qiuhe(m))\n",
    "#2.查找资料，将常用汉字（20000个左右）及其unicode编码（十六进制形式） 打印出来\n",
    "  #要求： 汉字的unicode编码（十六进制形式）的前两位相同的放在同一行，比如：\n",
    "with open(r'C:\\Users\\未来可期\\Desktop.txt') as f:\n",
    "          a = f.read()\n",
    "for j in range(len(a)):\n",
    "    print(str.decode(\"a[j]\"))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {},
   "outputs": [
    {
     "ename": "NameError",
     "evalue": "name 'raw_input' is not defined",
     "output_type": "error",
     "traceback": [
      "\u001b[1;31m---------------------------------------------------------------------------\u001b[0m",
      "\u001b[1;31mNameError\u001b[0m                                 Traceback (most recent call last)",
      "\u001b[1;32m<ipython-input-4-dffd00ad114e>\u001b[0m in \u001b[0;36m<module>\u001b[1;34m\u001b[0m\n\u001b[0;32m      2\u001b[0m \u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m      3\u001b[0m \u001b[1;32mimport\u001b[0m \u001b[0mos\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[1;32m----> 4\u001b[1;33m \u001b[0mtitle\u001b[0m \u001b[1;33m=\u001b[0m \u001b[0mraw_input\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;34m'请输入新建目录名称: '\u001b[0m\u001b[1;33m)\u001b[0m \u001b[1;31m#可以包括路径\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m\u001b[0;32m      5\u001b[0m \u001b[0mos\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mmkdir\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mtitle\u001b[0m\u001b[1;33m)\u001b[0m \u001b[1;31m#title两端不用引号，表示title是一个变量，而不\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m      6\u001b[0m \u001b[1;31m#2.统计一个文件个数超过20的文件夹中（比如C:\\Windows\\System32），\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n",
      "\u001b[1;31mNameError\u001b[0m: name 'raw_input' is not defined"
     ]
    }
   ],
   "source": [
    "#1.在当前工作文件夹下创建50个以test为前缀，不重名的文件夹。\n",
    "\n",
    "import os\n",
    "title = raw_input('请输入新建目录名称: ') #可以包括路径\n",
    "os.mkdir(title) #title两端不用引号，表示title是一个变量，而不\n",
    "#2.统计一个文件个数超过20的文件夹中（比如C:\\Windows\\System32），\n",
    "  #不同类型（后缀）文件的个数，并打印出来(选做)。"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "interpreter": {
   "hash": "a4c6f6dca0b39727a1d31abc575f26c9e9c5e97275968b776bf7d6bafbe246da"
  },
  "kernelspec": {
   "display_name": "Python 3.8.8 ('base')",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.8.8"
  },
  "orig_nbformat": 4
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
